class_name PlayerGroundState
extends GameplayStateMachine

@onready var player: Player = $"../../"


func _on_setup() -> void:
	var multiway_transition: MultiwayStateTransition = MultiwayStateTransition.new(
		[
			func(): return 0 if player.input_handler.is_action_pressed("crouch") or player.state_checker.is_head_collided else 1,
			func(): return 2 if player.input_handler.is_action_double_click_started_any(["move_left", "move_right"]) else 1 if player.input_handler.is_action_pressed_any(["move_left", "move_right"]) else 0
		],
		{
			[0, 0]: "CrouchState",
			[0, 1]: "StealthState",
			[0, 2]: "RollState",
			[1, 0]: "IdleState",
			[1, 1]: "WalkState",
			[1, 2]: "RunState",
		}
	)

	add_transition("GhostState", multiway_transition)
	add_transition("IdleState", multiway_transition)
	add_transition("WalkState", multiway_transition)
	add_transition("RunState", multiway_transition)
	add_transition("CrouchState", multiway_transition)
	add_transition("StealthState", multiway_transition)


func _on_enter() -> void:
	player.remove_tag(GameplayTagLibrary.Cooldown_Jump)
